-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix race conditions between caching reader and worker (again) #2308
Conversation
On master the following debug assertion triggered while loading a track:
|
I think we should hold off on releasing 2.2.3 for a bit until we're confident all these recent changes to CachingReader are working.
see #2235 |
The tests seem to fail because they don't keep an event loop running, although they expect signals to arrive. This does not work for queued connections. Looks like the test framework is insufficient for testing a correct implementation? At some point I have to stop, this is getting completely out of control. |
...and now MockedEngineBackendTest gets stuck. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I need to do some manual tests tonight. What was the debug assertion you are trying to solve? What is the race condition you experience? It is a real issue?
// Handle signals from worker thread | ||
connect(&m_worker, | ||
&CachingReaderWorker::trackLoaded, | ||
this, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work without a direct connection?
Do we have a Qt Main Loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't have an event loop then we must not use signals. Period.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Can you recall which assertion has failed? I still see no non my system. Did it occur in the 2.2 or master branch?
|
} | ||
|
||
void CachingReader::process() { | ||
ReaderStatusUpdate update; | ||
while (m_stateFIFO.read(&update, 1) == 1) { | ||
while (m_readerStatusUpdateFIFO.read(&update, 1) == 1) { | ||
DEBUG_ASSERT(m_state != State::Idle); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion may occur after ejecting a track and loading a new one.
Was this the one you have experienced?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments to the wrong/closed PR: #2305 (review)
This is the debug assertion that helped me discover the race condition. I refuse to remove it because it is correct unless someone provides a counterexample.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have checked the old version in 3e9e2ae before the fixes and I still don't see a reason why this debug assertion is not valid?
|
The whole design is broken and slots/signals are used incorrectly. CachingReader lives the main thread, receives signals from a worker thread and process()/read() are called from an engine thread. I surrender. |
Even more serious race conditions and design flaws.
I've also reverted some unintended renamings from the previous PR, sorry for the noise.